Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

276
Visualizações
Nodemailer throws "No recipients defined" error but email is actually sent

I am experiencing an unexpected behaviour from nodemailer:

here is my code:

  let transporter = nodemailer.createTransport({
   host: 'outlook.office365.com',



auth: {
  user: process.env.MAIL_USER, // generated ethereal user
  pass: process.env.MAIL_PASS, // generated ethereal password
},
   tls: {
    rejectUnauthorized: false
}});



 let info =  transporter.sendMail({

 from: '"Mark 👻"mymail@outlook.com', 
 to: "anothermailOfMine@gmail.com", 
 subject: "Hello ✔", 
 text: "Hello world?", 
 html: `<b>
 <a href='http://localhost:3000/activate_user/${result._id}'>
 <button>Activate 
 profile</button></a> 
 </b>`, // html body
 });

transporter.sendMail(info, function (err, info) {
if (err) {
console.log(err);
res.json(err);
} else {
  console.log(' mail sent');
res.json({success:true, message:''});
}})};

The sendMail method returns an error even if the mail is actually sent successfully, which means that the front-end never receives a positive response about the sending, that's the error i just mentioned:

Error: No recipients defined
at SMTPConnection._formatError 

I wonder if I am doing something wrong.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I did find out what the problem was eventually: the send mail method needed to be called in an asynchronous function.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda